package com.aaa.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "emp")
public class Emp implements UserDetails {
    @TableId(value = "eid",type = IdType.AUTO)
    private Integer eid;
    private String ename;
    private String eusername;
    private String epassword;
    private String phone;
    private Integer sex;
    private String state;
    private Integer rid;
    private String picture;
    private String hiredate;
    private String leavdate;
    @TableField(exist = false)
    private String rolename;

    @TableField(exist = false)
    private Collection authorties;
    public void setAuthorties(Collection authorties){
        this.authorties=authorties;
    }
    //获取权限
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorties;
    }
    //获取密码
    @Override
    public String getPassword() {
        return this.epassword;
    }
    //获取用户名密码
    @Override
    public String getUsername() {
        return this.eusername;
    }
    //用户是否过期:1过期
    @Override
    public boolean isAccountNonExpired() {
//        return this.state!=1?true:false;
        return true;
    }
    //用户是否被锁定：2锁定
    @Override
    public boolean isAccountNonLocked() {
//        return this.state!=2?true:false;
        return true;
    }
    //凭证是否过期：密码 3过期
    @Override
    public boolean isCredentialsNonExpired() {
//        return this.state!=3?true:false;
        return true;
    }
    //是否启用:4禁用
    @Override
    public boolean isEnabled() {
//        return this.state!=4?true:false;
        return true;
    }

}
